package com.harmontronics.hanma.paas.paas.dto.input.process;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * 流程设计
 *
 * @author paas-generator
 * @email paas-generator@harmontronics.com
 * @date 2021-04-01 15:11:16
 */
@Data
public class HmProcessJsonInput {


    /**
     * 流程id
     */
    @ApiModelProperty(value = "流程id")
    @NotNull(message = "hm.pass.field_non_nullable")
    private Long id;
    /**
     * 流程设计json
     */
    @ApiModelProperty(value = "流程设计json")
    @NotNull(message = "hm.pass.field_non_nullable")
    @NotEmpty(message = "hm.pass.field_non_nullable")
    @NotBlank(message = "hm.pass.field_non_nullable")
    private String json;


    public String decodeJson(){
        try {
            return URLDecoder.decode(this.json, "UTF-8");
        }catch (UnsupportedEncodingException ex){
            ex.printStackTrace();
            return null;
        }
    }

}
